|
|
|
| Table C.2 Records Returned Based on the Type of JOIN Used | | JOIN Type Table | Records from Left Table | Records from Right Table | | INNER | Only records with corresponding record in right table | Only records with corresponding record in left table | | LEFT | All records | Only records with corresponding record in left table | | RIGHT | Only records with corresponding record in right table | All reocords |
|
|
|
|
|
|
To further understand these concepts, consider the sample database with its Customers and Salesperson tables. In that database, you created a small information set in the tables consisting of ten customers and four salespeople. Two of the customers have no salesperson listed, and one of the salespeople has no customers (he's a new guy!). You select the same fields with each JOIN but specify an INNER JOIN, LEFT JOIN, and RIGHT JOIN (see Listing C.7). Figure C.4 shows the two base-data tables from which this listing is working. Figure C.5 shows the resulting recordsets for each of the JOIN operations. |
|
|
|
|
|
|
|
|
Figure C.4
The Customers and Salesmen tables are RIGHT
JOINED to match salesmen to their customers. |
|
|
|
|
|
|
|
|
Listing C.7 JOIN.TXTExamples of the Three JOIN Types |
|
|
|
|
|
|
|
|
'**************************
'Select using an INNER JOIN
'**************************
SELECT CS.Lastname, CS.Firstname, SL.Saleslast, SL.Salesfirst _
FROM Customers AS CS, Salesmen AS SL, _ |
|
|
|
|
|